<!DOCTYPE html>
<html lang="zh" xmlns="http://www.w3.org/1999/html">

<head>
    <meta charset="UTF-8"/>
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <title>配件管理-配件采购信息</title>

    <link href="../plugin/bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="../plugin/bootstrap-table-1.11.1/bootstrap-table.min.css" rel="stylesheet"/>
    <link href="../plugin/sweetalert-6.6.2/sweetalert2.min.css" rel="stylesheet"/>
    <link href="../plugin/jstree/jstree.min.css" rel="stylesheet">
    <link href="../plugin/bootstrap-fileinput-master/fileinput.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="../plugin/fileupload/css/jquery.fileupload.css">
    <link href="../plugin/bootstrap-3.3.7/plugin/datatimepicker/bootstrap-datetimepicker.min.css" rel="stylesheet"/>


    <script src="../plugin/jquery-3.2.1/jquery-3.2.1.min.js"></script>
    <script src="../plugin/bootstrap-3.3.7/js/bootstrap.min.js"></script>
    <script src="../plugin/bootstrap-table-1.11.1/bootstrap-table.js"></script>
    <script src="../plugin/bootstrap-table-1.11.1/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="../plugin/bootstrap-3.3.7/plugin/datatimepicker/bootstrap-datetimepicker.min.js"></script>
    <script src="../plugin/bootstrap-3.3.7/plugin/datatimepicker/bootstrap-datetimepicker.zh-CN.js"></script>
    <script src="../plugin/sweetalert-6.6.2/sweetalert2.min.js"></script>
    <script src="../plugin/jquery-3.2.1/jquery.formautofill.min.js"></script>
    <script src="../plugin/soul/utils3.js"></script>
    <script src='../js/base.js'></script>
    <!--<script src="../plugin/soulUtils/soul_utils.js"></script>-->
    <script src='../plugin/jquery-3.2.1/jquery.form.js'></script>
    <script src="../plugin/jquery-3.2.1/jquery.serializejson.js"></script>
    <script src="../plugin/jstree/jstree.min.js"></script>
    <script src="../plugin/bootstrap-fileinput-master/fileinput.min.js"></script>
</head>

<body>

<!-- 设备信息导入模态框 -->
<div class="modal fade in" data-backdrop="static" id="accessoryApplyRecord_modal_edit">
    <form id="ajaxForm"   enctype="multipart/form-data" onsubmit="return false">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button class="close" data-dismiss="modal">
                        <span>&times;</span>
                    </button>
                    <h4 class="modal-title">
                        <b>配件采购单信息</b>
                    </h4>
                </div>
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div class="form-group"> <label class="col-sm-2 control-label">医院名称</label><div class="col-sm-9">
                            <select class="form-control" id="hospitalId" name="hospitalId" class="form-control"></select>
                            &nbsp;&nbsp;
                        </div>
                        </div>
                        <div class="form-group"><label class="col-sm-2 control-label">导入文件:</label>
                            <div class="col-sm-9">
                                <input type="file" id="file" name="file" class="form-control"  placeholder="请输入文本"></div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button class="btn btn-primary"   onclick="doUpload()">确认</button>
                        <button class="btn btn-default" data-dismiss="modal">取消</button>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>



<script>
    $(function () {

        var resp = AjaxUtil.isLogin();
        if (!resp) return;
        var module = 'accessoryProcurement';
        var query = [{
            id: 'hospital',
            type: 'select',
            name: '医院名称',
            paramName:'hospitalId',
            items: 'hospital/selectItem'
        },{
            id: 'departmentName',
            type: 'text',
            name: '科室',
            paramName: 'departmentName',
            palceholder: ''
        },{
            id: 'accessoryName',
            type: 'text',
            name: '备件名称',
            paramName: 'accessoryName',
            palceholder: ''
        },{
            id: 'producerOrigin',
            type: 'text',
            name: '厂家产地',
            paramName: 'producerOrigin',
            palceholder: ''
        },{
            id: 'phone',
            type: 'text',
            name: '联系方式',
            paramName: 'phone',
            palceholder: ''
        },{
            id: 'begin_purchaseDate',
            type: 'text',
            name: '购买开始时间',
            paramName: 'begin_purchaseDate',
            palceholder: ''
        }, {
            id: 'end_purchaseDate',
            type: 'text',
            name: '购买结束时间',
            paramName: 'end_purchaseDate',
            palceholder: ''
        }];
        var toolbar = {
            default: [true, true, true, true],// back;add;edit;remove
            dialog: [60, 2, 9],//对话框参数:模态框宽度(百分比);表单标题宽度;表单输入框宽度
            extra: [{
                name: '导入',
                type:'file',
                glyphicon: 'import',
                onclick: 'import',
            },{
                name: '导出',
                glyphicon: 'export',
                onclick: 'export',
            }]
        };
        // 表单内容配置
        var formElement = [{
            action: [false, true],
            type: 'hidden', // 表单类型
            name: 'accessoryProcurementId', // 字段名称
        }, {
            action: [true, true],
            type: 'text',
            label: '配件名称',
            name: 'accessoryName',
        },{
            action: [true, true],
            id: 'hospitalId',
            type: 'select',
            label: '所属医院',
            name: 'hospitalId',
            items: "hospital/selectItem"
        }, {
            action: [true, true],
            type: 'text',
            label: '科室',
            name: 'departmentName',
        }, {
            action: [true, true],
            type: 'text',
            label: '申请人',
            name: 'applyPeople',
        }, {
            action: [true, true],
            type: 'text',
            label: '数量',
            name: 'amount',
        }, {
            action: [true, true],
            type: 'text',
            label: '单价',
            name: 'unit',
        }, {
            action: [true, true],
            type: 'text',
            label: '总价',
            name: 'totalPrice',
        },{
            action: [true, true],
            type: 'text',
            label: '付款情况',
            name: 'paySituation',
        },{
            action: [true, true],
            type: 'text',
            label: '发票类型',
            name: 'invoiceType',
        },{
            action: [true, true],
            type: 'text',
            label: '发票是否收到',
            name: 'invoiceIsReceived',
        },{
            action: [true, true],
            type: 'text',
            label: '厂家产地',
            name: 'producerOrigin',
        },{
            action: [true, true],
            type: 'text',
            label: '联系方式',
            name: 'phone',
        },{
            action: [true, true],
            type: 'datetime',
            label: '购买日期',
            name: 'purchaseDate',
        }];

        var bootstrapTable = {
            url: '',
            columns: [{
                radio: true
            },{
                field: 'code',
                title: '采购单编号',
            },{
                field: 'accessoryName',
                title: '配件名称',
            },{
                field: 'hospitalName',
                title: '医院名称',
            },{
                field: 'departmentName',
                title: '科室',
            },{
                field: 'applyPeople',
                title: '申请人',
            },{
                field: 'amount',
                title: '数量',
            },{
                field: 'unitPrice',
                title: '单价',
            },{
                field: 'unit',
                title: '单位',
            },{
                field: 'totalPrice',
                title: '总价',
            },{
                field: 'paySituation',
                title: '发票类型',
            },{
                field: 'invoiceType',
                title: '发票是否收到',
            },{
                field: 'producerOrigin',
                title: '厂家产地',
            },{
                field: 'phone',
                title: '联系方式',
            },{
                field: 'purchaseDate',
                title: '购买日期',
                formatter: BootstrapTableUtil.formatter.datetime
            }]
        };

        accessoryProcurement = SingleTablePageCreateUtil.createInstance(module, query, toolbar, formElement, bootstrapTable);

        accessoryProcurement.onRemoveSubmitBefore = function (row) {
            row.purchaseDate = FormatUtil.formatDateTime(row.purchaseDate);
            return row;
        };

        accessoryProcurement.onEditModalShowBefore = function (row) {
            row.purchaseDate = FormatUtil.formatDateTime(row.purchaseDate);
            return row;
        };

        //点击导入显示模态框
        accessoryProcurement.import = function () {
            $('#hospitalId').empty();
            var resp=AjaxUtil.getJson('hospital/selectItem').obj;
            var s = '<option value>'+'请点击下拉框选择'+'</option>';
            for(var i=0;i<resp.length;i++){
                s+='<option value="'+resp[i].value+'">'+resp[i].name+'</option>';
            }
            $('#hospitalId').append(s);
            $('#accessoryApplyRecord_modal_edit').modal('show');
        };

        //点击确认按钮提交表单内容
        doUpload=function() {
            var formData = new FormData($( "#ajaxForm" )[0]);
            $.ajax({
                url: '/accessoryProcurement/excelImport?token='+BaseConfig.token ,
                type: 'POST',
                data: formData,
                async: true,
                cache: false,
                contentType: false,
                processData: false,
                success: function (res) {
                    if(res.code==412){
                        SwalUtil.error(res.msg);
                    }
                    if (res.code == 200) {
                        $('#accessoryApplyRecord_modal_edit').modal('hide');
                        SwalUtil.success(res.msg);
                        $('#accessoryProcurement_table').bootstrapTable('refresh');
                    } },
            });
            return false;
        }

        //点击导出
        accessoryProcurement.export = function () {
            var par = $('#accessoryProcurement_form').serializeJSON();
            var url = '';
            for(var key in par){
                url += '&'+ key + '=' +par[key];
            }
            url = BaseConfig.preUrl+'accessoryProcurement/downloadExcel?token=' + BaseConfig.token+url;
            window.open(url);
        };

        // 初始化开始时间和结束时间
        $('#begin_purchaseDate').val(DateUtil.thirtyDayBeforeDate());
        $('#end_purchaseDate').val(DateUtil.nowDate());
        $('#begin_purchaseDate').datetimepicker({
            language: 'zh-CN',
            format: 'yyyy-mm-dd',
            minView: 2,
            autoclose: true,
        });
        $('#end_purchaseDate').datetimepicker({
            language: 'zh-CN',
            format: 'yyyy-mm-dd',
            minView: 2,
            autoclose: true,
        });

    });
    var DateUtil = {
        nowDate: function () {
            return FormatUtil.formatDate(new Date().getTime());
        },
        thirtyDayBeforeDate: function () {
            var now = new Date().getTime();
            now -= 1000 * 60 * 60 * 24 * 365*5;
            return FormatUtil.formatDate(now);
        }
    };

</script>


</body>

</html>